1 00:00:00,560 --> 00:00:07,220 All right, So I'm in my zombie game and we have our boulder traps set up just the parts, no scripts. 2 00:00:07,220 --> 00:00:10,160 We've got to ramp our stop or our boulder and a trigger. 3 00:00:10,160 --> 00:00:12,280 So we need to make this work. 4 00:00:12,290 --> 00:00:18,740 Let's go over to our boulder trap and start doing some scripting on the boulder trap level. 5 00:00:18,740 --> 00:00:20,300 I'm going to add a script here. 6 00:00:20,300 --> 00:00:22,940 I'll hit the plus sign script. 7 00:00:22,940 --> 00:00:27,890 And the reason I have it on this level is this script is going to interact with more than one part. 8 00:00:27,890 --> 00:00:31,280 If it was only going to interact with one part, I'd put it on that part. 9 00:00:31,280 --> 00:00:37,310 But we are going to have to interact with both the stopper and the trigger and actually we're going 10 00:00:37,310 --> 00:00:40,940 to do the boulder in the next video because we want to put sound on it. 11 00:00:40,940 --> 00:00:44,180 So I'm going to call this script trigger it. 12 00:00:44,180 --> 00:00:44,600 Right. 13 00:00:44,600 --> 00:00:46,280 Hopefully that's not too close to a name. 14 00:00:46,280 --> 00:00:47,290 Is Trigger, right? 15 00:00:47,330 --> 00:00:48,740 Trigger It is the script. 16 00:00:48,740 --> 00:00:51,440 And you got a little icon that makes it look like a script, too. 17 00:00:51,680 --> 00:00:54,650 So let's get a variable for our boulder trap. 18 00:00:55,060 --> 00:00:58,940 Let's say a boulder trap, and that's script dot parent. 19 00:00:59,210 --> 00:01:02,060 And then in the boulder trap, we have a trigger. 20 00:01:02,060 --> 00:01:08,990 We're going to need a variable for that trigger boulder trap trigger, right? 21 00:01:08,990 --> 00:01:14,950 So Boulder trap is on the model level, and the trigger is one child underneath, right? 22 00:01:14,960 --> 00:01:17,420 The first child of the boulder trap. 23 00:01:18,140 --> 00:01:18,740 Cool. 24 00:01:18,740 --> 00:01:20,420 And then we'll get the stopper. 25 00:01:20,420 --> 00:01:21,810 Stopper is the same thing, right? 26 00:01:21,830 --> 00:01:24,680 We have Boulder trap dot and you can even see it there. 27 00:01:24,680 --> 00:01:25,550 Stopper. 28 00:01:25,820 --> 00:01:26,210 Cool. 29 00:01:26,210 --> 00:01:28,010 If you don't see it, then you're going to have to look around. 30 00:01:28,010 --> 00:01:28,670 Something happen. 31 00:01:28,670 --> 00:01:29,600 Something went wrong. 32 00:01:30,020 --> 00:01:35,390 All right, Now we need a function to handle our touch event for the trigger. 33 00:01:35,390 --> 00:01:40,940 So when I say local function, we're only going to have one touch event in this in this script. 34 00:01:40,940 --> 00:01:42,890 So I'm going to call this on touch. 35 00:01:43,790 --> 00:01:45,230 What's that other part? 36 00:01:45,230 --> 00:01:45,620 Right. 37 00:01:45,620 --> 00:01:47,780 Whenever we do a touch event, we're going to get another part. 38 00:01:47,780 --> 00:01:49,460 That's the part that touched our part. 39 00:01:49,790 --> 00:01:52,520 And the part that we're touching is the trigger. 40 00:01:52,790 --> 00:01:57,920 So we have the trigger touched, connect on touch. 41 00:01:57,920 --> 00:02:01,220 So this will be like a foot or something like that? 42 00:02:01,220 --> 00:02:02,150 Probably a foot. 43 00:02:02,150 --> 00:02:03,170 We're going to step on it. 44 00:02:03,470 --> 00:02:05,210 So if it is a foot. 45 00:02:05,840 --> 00:02:12,650 The parent will be the character, and then we'll be able to find a humanoid proving that it is a character 46 00:02:12,650 --> 00:02:14,250 or a non playing character. 47 00:02:14,270 --> 00:02:17,090 If a ball rolls over it, we're not going to trigger the trap. 48 00:02:17,300 --> 00:02:20,510 So I'm going to look for the humanoid local cube. 49 00:02:20,540 --> 00:02:21,380 That's my variable. 50 00:02:21,600 --> 00:02:32,690 Some other part, maybe a foot parent find first child that is a humanoid. 51 00:02:33,080 --> 00:02:39,380 So if this is the character, there will be a humanoid, if it's the character and then let's do it 52 00:02:39,380 --> 00:02:44,930 if statement just to make sure, make sure it wasn't something weird that happened like a ball or I 53 00:02:44,930 --> 00:02:46,520 don't know, something else, a tree. 54 00:02:47,210 --> 00:02:48,380 Let's go ahead. 55 00:02:48,380 --> 00:02:53,780 And now that we know that it's the humanoid, we are going to remove the stopper. 56 00:02:54,650 --> 00:02:55,970 How do we remove the stopper? 57 00:02:55,970 --> 00:03:00,680 I'm always going to put hinges on it, but I'm just going to make it easy because this is our first 58 00:03:01,160 --> 00:03:02,880 kind of our first game asset, right? 59 00:03:02,930 --> 00:03:09,770 We did some simple ones with the coin and the health but let's do stopper will make can collide equal 60 00:03:09,770 --> 00:03:15,950 to false so it's essentially not holding back the ball, the the ball or the boulder and then we'll 61 00:03:15,950 --> 00:03:20,870 get the stopper transparency and make it invisible. 62 00:03:20,870 --> 00:03:23,360 One essentially, boom, it's gone. 63 00:03:23,720 --> 00:03:25,730 Let's go ahead and try it out, see what we got. 64 00:03:29,410 --> 00:03:31,120 You should put a print statement in there, too. 65 00:03:31,150 --> 00:03:34,000 That's a good way to check to see what's happening. 66 00:03:34,270 --> 00:03:36,350 We can go here to view output window. 67 00:03:36,370 --> 00:03:38,140 We don't have any print statements in there. 68 00:03:38,170 --> 00:03:39,090 I know this will work. 69 00:03:39,100 --> 00:03:39,880 It's pretty simple. 70 00:03:39,880 --> 00:03:40,930 But if it doesn't. 71 00:03:42,910 --> 00:03:44,920 So there's no damaged script, so it doesn't hurt you. 72 00:03:44,920 --> 00:03:47,560 But we're going to do that, too, if you. 73 00:03:47,560 --> 00:03:48,640 If it doesn't work for you. 74 00:03:48,640 --> 00:03:55,570 If the boulder doesn't go, what you should do is put print statements above the if statement and below 75 00:03:55,570 --> 00:04:00,160 the statement down in here to see what's being printed out. 76 00:04:00,190 --> 00:04:08,440 Typically this is spelt wrong or you forgot that or you'll see something red down here, red and scary, 77 00:04:08,440 --> 00:04:09,910 and then you'll know that something went wrong. 78 00:04:09,910 --> 00:04:11,860 So that's how you do some troubleshooting. 79 00:04:12,100 --> 00:04:12,550 All right. 80 00:04:12,550 --> 00:04:17,110 So the next video we're going to add to this, we're going to have to make the ball go back. 81 00:04:17,120 --> 00:04:18,520 We're going to have to put damage on there. 82 00:04:18,520 --> 00:04:20,350 We're going to put a sound on there.